#ifndef RAWDATA_H_
#define RAWDATA_H_

#include <vector>
#include <string>

class RawData
{
public:
	std::string path;
	int wordSize;
	std::vector<int> dictionary;
	int lastSize;

protected:
	std::vector<int> data;

	RawData(std::string &path, int wordSize);
	RawData(std::string &path, int wordSize, std::vector<int> &dictionary,
			int lastSize);
};

class RawDataInput: public RawData
{
private:
	std::vector<int> index;
	void buildDictionary();

public:
	struct Comparator
	{
		int word;
		int count;
		Comparator() :
				word(0), count(0)
		{
		}
		bool operator()(const Comparator& a, const Comparator& b)
		{
			return a.count > b.count;
		}
	} cmp;
	std::vector<Comparator> dictBuilder;


	RawDataInput(std::string &path, int wordSize);
	int length();
	int get(int i);
	int operator[](int i)
	{
		return get(i);
	}
};

class RawDataOutput: public RawData
{
public:
	RawDataOutput(std::string &path, int wordSize, std::vector<int> &dictionary,
			int lastSize);
	void put(int symbol);
	void commit();
};

#endif /* RAWDATA_H_ */
